/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.registration.business.security.entity;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import org.eclipse.persistence.annotations.Mutable;

/**
 *
 * @author Stefano
 */
@Entity
public class SystemNotification implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;
    
    @JoinColumn(referencedColumnName = "email")
    @ManyToOne(optional = false)
    private User username;
    
    @JoinColumn(referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Event event;
    
    @NotNull
    private boolean unread;
    
    @Temporal(TemporalType.TIMESTAMP)
    private Calendar nextSunny;
    
    private int weathercode;

    public SystemNotification() {
    }
    
    public SystemNotification(User user, Event event) {
        this.username = user;
        this.event = event;
        this.unread = true;
        this.nextSunny=null;
    }
    
    public int getWeatherCode()
    {
        return this.weathercode;
    }
    
    public void setweatherCode(int value)
    {
        this.weathercode=value;
    }
    
    public Calendar getNextSunny()
    {
        return this.nextSunny;
    }
    
    public void setnextSunny(Calendar value)
    {
       this.nextSunny=value; 
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
    
    public boolean getUnread() {
        return unread;
    }

    public void setUnread(boolean unread) {
        this.unread = unread;
    }
    
    public User getUsername() {
        return username;
    }

    public void setUsername(User username) {
        this.username = username;
    }

    public Event getEvent() {
        return event;
    }

    public void setEvent(Event event) {
        this.event = event;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (int) id;
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SystemNotification)) {
            return false;
        }
        SystemNotification other = (SystemNotification) object;
        if (this.id != other.id) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.registration.business.security.entity.SystemNotification[ id=" + id + " ]";
    }
    
}
